﻿CREATE TABLE [dbo].[Tasks] (
    [TaskId]                 BIGINT           IDENTITY (1, 1) NOT NULL,
    [TaskDefinitionId]       BIGINT           NOT NULL,
    [Name]                   NVARCHAR (100)   NOT NULL,
    [Description]            NVARCHAR (1000)  NOT NULL,
    [InitiatorCorrelationId] UNIQUEIDENTIFIER NOT NULL,
    [TaskPriority]           BIGINT           NOT NULL,
    [TaskStatus]             BIGINT           NOT NULL,
    [CreatedDate]            DATETIME         NOT NULL,
    [CreatedBy]              BIGINT           NOT NULL,
    [ModifiedDate]           DATETIME         NULL,
    [ModifiedBy]             BIGINT           NULL,
    CONSTRAINT [PK_Tasks] PRIMARY KEY CLUSTERED ([TaskId] ASC),
    CONSTRAINT [FK_Tasks_TaskDefinitions] FOREIGN KEY ([TaskDefinitionId]) REFERENCES [dbo].[TaskDefinitions] ([TaskDefinitionId]),
    CONSTRAINT [FK_Tasks_TaskPriorities] FOREIGN KEY ([TaskPriority]) REFERENCES [dbo].[TaskPriorities] ([TaskPriorityId]),
    CONSTRAINT [FK_Tasks_TaskStatuses1] FOREIGN KEY ([TaskStatus]) REFERENCES [dbo].[TaskStatuses] ([TaskStatusId])
);

